package com.inmobi.androidsdk.impl;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.os.Build;
import com.inmobi.androidsdk.IMAdRequest;
import com.inmobi.androidsdk.IMAdRequest.EducationType;
import com.inmobi.androidsdk.IMAdRequest.EthnicityType;
import com.inmobi.androidsdk.IMAdRequest.GenderType;
import com.inmobi.androidsdk.IMAdRequest.IMIDType;
import com.inmobi.androidsdk.bootstrapper.ConfigParams;
import com.inmobi.androidsdk.bootstrapper.Initializer;
import com.inmobi.commons.IMCommonUtil;
import com.inmobi.commons.internal.InternalSDKUtil;
import com.inmobi.commons.internal.Log;
import com.inmobi.commons.uid.UID;
import com.inmobi.commons.uid.UIDHelper;
import com.inmobi.re.container.WrapperFunctions;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
import java.util.UUID;

public final class UserInfo
{
  private String A;
  private int B = -1;
  private int C;
  private long D;
  private Activity E;
  boolean a;
  private String b;
  private String c;
  private String d;
  private String e;
  private String f;
  private String g;
  private String h;
  private String i;
  private String j;
  private String k;
  private LocationManager l;
  private double m;
  private double n;
  private double o;
  private boolean p;
  private Context q;
  private String r;
  private String s = null;
  private String t = null;
  private String u = null;
  private String v = null;
  private String w = null;
  private String x = null;
  private IMAdRequest y;
  private Random z;

  public UserInfo(Activity paramActivity)
  {
    this.E = paramActivity;
    this.q = paramActivity.getApplicationContext();
    this.z = new Random();
  }

  private String a()
  {
    return this.j;
  }

  private void a(double paramDouble)
  {
    this.m = paramDouble;
  }

  private void a(int paramInt)
  {
    this.g = Integer.toString(paramInt);
  }

  private void a(long paramLong)
  {
    this.D = paramLong;
  }

  private void a(Context paramContext)
  {
    try
    {
      if (this.A == null)
        this.A = paramContext.getSharedPreferences("inmobisdkaid", 0).getString("A_ID", null);
      if (this.A == null)
      {
        this.A = UUID.randomUUID().toString();
        SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("inmobisdkaid", 0).edit();
        localEditor.putString("A_ID", this.A);
        localEditor.commit();
      }
      return;
    }
    catch (Exception localException)
    {
    }
  }

  private void a(Location paramLocation)
  {
    if (paramLocation != null)
    {
      b(true);
      a(paramLocation.getLatitude());
      b(paramLocation.getLongitude());
      c(paramLocation.getAccuracy());
      a(paramLocation.getTime());
    }
  }

  private void a(LocationManager paramLocationManager)
  {
    try
    {
      this.l = paramLocationManager;
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  private void a(IMAdRequest paramIMAdRequest)
  {
    this.y = paramIMAdRequest;
  }

  private void a(String paramString)
  {
    this.b = paramString;
  }

  private void a(boolean paramBoolean)
  {
    this.a = paramBoolean;
  }

  private LocationManager b()
  {
    try
    {
      LocationManager localLocationManager = this.l;
      return localLocationManager;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  private void b(double paramDouble)
  {
    this.n = paramDouble;
  }

  private void b(int paramInt)
  {
    this.C = paramInt;
  }

  private void b(String paramString)
  {
    this.c = paramString;
  }

  private void b(boolean paramBoolean)
  {
    this.p = paramBoolean;
  }

  private void c(double paramDouble)
  {
    this.o = paramDouble;
  }

  private void c(String paramString)
  {
    this.d = paramString;
  }

  private boolean c()
  {
    if (this.y != null)
      return this.y.isLocationInquiryAllowed();
    return true;
  }

  private void d(String paramString)
  {
    this.e = paramString;
  }

  private boolean d()
  {
    return this.a;
  }

  private void e()
  {
    try
    {
      if (b() == null)
        a((LocationManager)getApplicationContext().getSystemService("location"));
      if (b() != null)
      {
        LocationManager localLocationManager = b();
        Criteria localCriteria = new Criteria();
        if (getApplicationContext().checkCallingOrSelfPermission("android.permission.ACCESS_FINE_LOCATION") == 0)
          localCriteria.setAccuracy(1);
        while (true)
        {
          localCriteria.setCostAllowed(false);
          String str = localLocationManager.getBestProvider(localCriteria, true);
          if ((isValidGeoInfo()) || (str == null))
            break;
          Location localLocation = localLocationManager.getLastKnownLocation(str);
          Log.debug("InMobiAndroidSDK_3.7.0", "lastBestKnownLocation: " + localLocation);
          if (localLocation == null)
          {
            localLocation = f();
            Log.debug("InMobiAndroidSDK_3.7.0", "lastKnownLocation: " + localLocation);
          }
          a(localLocation);
          return;
          if (getApplicationContext().checkCallingOrSelfPermission("android.permission.ACCESS_COARSE_LOCATION") == 0)
            localCriteria.setAccuracy(2);
        }
      }
    }
    catch (Exception localException)
    {
      Log.debug("InMobiAndroidSDK_3.7.0", "Error getting the Location Info ", localException);
    }
  }

  private void e(String paramString)
  {
    this.f = paramString;
  }

  private Location f()
  {
    if (b() == null)
      a((LocationManager)getApplicationContext().getSystemService("location"));
    if (b() != null)
    {
      LocationManager localLocationManager = b();
      List localList = localLocationManager.getProviders(true);
      for (int i1 = -1 + localList.size(); i1 >= 0; i1--)
      {
        String str = (String)localList.get(i1);
        if (localLocationManager.isProviderEnabled(str))
        {
          Location localLocation = localLocationManager.getLastKnownLocation(str);
          if (localLocation != null)
            return localLocation;
        }
      }
    }
    return null;
  }

  private void f(String paramString)
  {
    this.h = paramString;
  }

  private void g()
  {
    int i1 = getApplicationContext().checkCallingOrSelfPermission("android.permission.ACCESS_COARSE_LOCATION");
    int i2 = getApplicationContext().checkCallingOrSelfPermission("android.permission.ACCESS_FINE_LOCATION");
    if ((i1 != 0) && (i2 != 0))
    {
      a(true);
      return;
    }
    a(false);
  }

  private void g(String paramString)
  {
    this.i = paramString;
  }

  private void h()
  {
    String str3;
    String str6;
    if (a() == null)
    {
      h(Build.BRAND);
      Locale localLocale = Locale.getDefault();
      str3 = localLocale.getLanguage();
      if (str3 == null)
        break label373;
      str6 = str3.toLowerCase(Locale.ENGLISH);
      String str8 = localLocale.getCountry();
      if (str8 != null)
        str6 = str6 + "_" + str8.toLowerCase(Locale.ENGLISH);
    }
    while (true)
    {
      g(str6);
      try
      {
        Context localContext = getApplicationContext();
        PackageManager localPackageManager = localContext.getPackageManager();
        ApplicationInfo localApplicationInfo = localPackageManager.getApplicationInfo(localContext.getPackageName(), 128);
        if (localApplicationInfo != null)
        {
          a(localApplicationInfo.packageName);
          b(localApplicationInfo.loadLabel(localPackageManager).toString());
        }
        PackageInfo localPackageInfo = localPackageManager.getPackageInfo(localContext.getPackageName(), 128);
        if (localPackageInfo != null)
        {
          str7 = localPackageInfo.versionName;
          if ((str7 == null) || (str7.equals("")))
            str7 = localPackageInfo.versionCode + "";
          if ((str7 != null) && (!str7.equals("")))
            c(str7);
          e(UIDHelper.getODIN1(UIDHelper.getAndroidId(getApplicationContext())));
          a(this.z.nextInt());
          if (this.y != null)
          {
            str2 = this.y.getIDType(IMAdRequest.IMIDType.ID_LOGIN);
            str1 = this.y.getIDType(IMAdRequest.IMIDType.ID_SESSION);
            i1 = IMCommonUtil.getDeviceIdMask();
            f(Initializer.getConfigParams(this.q).getUID().getUidMap(str2, str1, i1, getRandomKey()));
            if (this.q != null)
              a(this.q.getApplicationContext());
            d(InternalSDKUtil.getConnectivityType(getApplicationContext()));
            int i2;
            try
            {
              i2 = WrapperFunctions.getCurrentOrientationInFixedValues(i());
              if (i2 == 9)
              {
                b(2);
                return;
                label373: String str4 = (String)System.getProperties().get("user.language");
                String str5 = (String)System.getProperties().get("user.region");
                if ((str4 == null) || (str5 == null))
                  break label515;
                str6 = str4 + "_" + str5;
                if (str6 != null)
                  continue;
                str6 = "en";
                continue;
              }
              if (i2 == 8)
              {
                b(4);
                return;
              }
            }
            catch (Exception localException1)
            {
              Log.debug("InMobiAndroidSDK_3.7.0", "Error getting the orientation info ", localException1);
              return;
            }
            if (i2 == 0)
            {
              b(3);
              return;
            }
            b(1);
            return;
          }
        }
      }
      catch (Exception localException2)
      {
        while (true)
        {
          continue;
          int i1 = 0;
          String str1 = null;
          String str2 = null;
          continue;
          String str7 = null;
          continue;
          label515: str6 = str3;
        }
      }
    }
  }

  private void h(String paramString)
  {
    this.j = paramString;
  }

  private Activity i()
  {
    return this.E;
  }

  private void i(String paramString)
  {
    this.k = paramString;
  }

  public String getAdUnitSlot()
  {
    return this.u;
  }

  public int getAge()
  {
    if (this.y != null)
      return this.y.getAge();
    return 0;
  }

  public String getAid()
  {
    return this.A;
  }

  public String getAppBId()
  {
    return this.b;
  }

  public String getAppDisplayName()
  {
    return this.c;
  }

  public String getAppVer()
  {
    return this.d;
  }

  public Context getApplicationContext()
  {
    return this.q;
  }

  public String getAreaCode()
  {
    if (this.y != null)
      return this.y.getAreaCode();
    return null;
  }

  public String getDateOfBirth()
  {
    IMAdRequest localIMAdRequest = this.y;
    String str = null;
    if (localIMAdRequest != null)
    {
      Calendar localCalendar1 = this.y.getDateOfBirth();
      str = null;
      if (localCalendar1 != null)
      {
        Calendar localCalendar2 = this.y.getDateOfBirth();
        str = localCalendar2.get(1) + "-" + (1 + localCalendar2.get(2)) + "-" + localCalendar2.get(5);
      }
    }
    return str;
  }

  public IMAdRequest.EducationType getEducation()
  {
    if (this.y != null)
      return this.y.getEducation();
    return null;
  }

  public IMAdRequest.EthnicityType getEthnicity()
  {
    if (this.y != null)
      return this.y.getEthnicity();
    return null;
  }

  public IMAdRequest.GenderType getGender()
  {
    if (this.y != null)
      return this.y.getGender();
    return null;
  }

  public long getGeoTS()
  {
    return this.D;
  }

  public int getIncome()
  {
    if (this.y != null)
      return this.y.getIncome();
    return 0;
  }

  public String getInterests()
  {
    if (this.y != null)
      return this.y.getInterests();
    return null;
  }

  public String getKeywords()
  {
    if (this.y != null)
      return this.y.getKeywords();
    return null;
  }

  public double getLat()
  {
    return this.m;
  }

  public double getLocAccuracy()
  {
    return this.o;
  }

  public String getLocalization()
  {
    return this.i;
  }

  public String getLocationWithCityStateCountry()
  {
    if (this.y != null)
      return this.y.getLocationWithCityStateCountry();
    return null;
  }

  public double getLon()
  {
    return this.n;
  }

  public String getNetworkType()
  {
    return this.e;
  }

  public String getODINId()
  {
    return this.f;
  }

  public int getOrientation()
  {
    return this.C;
  }

  public String getPhoneDefaultUserAgent()
  {
    if (this.r == null)
      return "";
    return this.r;
  }

  public String getPostalCode()
  {
    if (this.y != null)
      return this.y.getPostalCode();
    return null;
  }

  public String getRandomKey()
  {
    return this.g;
  }

  public String getRefTagKey()
  {
    return this.s;
  }

  public String getRefTagValue()
  {
    return this.t;
  }

  public int getRefreshType()
  {
    return this.B;
  }

  public Map<String, String> getRequestParams()
  {
    if (this.y != null)
      return this.y.getRequestParams();
    return null;
  }

  public String getRsakeyVersion()
  {
    return UIDHelper.getRSAKeyVersion();
  }

  public String getScreenDensity()
  {
    return this.x;
  }

  public String getScreenSize()
  {
    return this.w;
  }

  public String getSearchString()
  {
    if (this.y != null)
      return this.y.getSearchString();
    return null;
  }

  public String getSiteId()
  {
    return this.k;
  }

  public String getSlotId()
  {
    return this.v;
  }

  public String getUIDMapEncrypted()
  {
    return this.h;
  }

  public boolean isValidGeoInfo()
  {
    return this.p;
  }

  public void setAdUnitSlot(String paramString)
  {
    this.u = paramString;
  }

  public void setPhoneDefaultUserAgent(String paramString)
  {
    this.r = paramString;
  }

  public void setRefTagKey(String paramString)
  {
    this.s = paramString;
  }

  public void setRefTagValue(String paramString)
  {
    this.t = paramString;
  }

  public void setRefreshType(int paramInt)
  {
    if ((paramInt != 1) || (paramInt != 0))
      this.B = -1;
    this.B = paramInt;
  }

  public void setScreenDensity(String paramString)
  {
    this.x = paramString;
  }

  public void setScreenSize(String paramString)
  {
    this.w = paramString;
  }

  public void setSlotId(String paramString)
  {
    this.v = paramString;
  }

  public void updateInfo(String paramString, IMAdRequest paramIMAdRequest)
  {
    while (true)
    {
      try
      {
        a(paramIMAdRequest);
        h();
        i(paramString);
        if (paramIMAdRequest != null)
        {
          b(false);
          if (!c())
            break label78;
          if (paramIMAdRequest.getCurrentLocation() != null)
          {
            a(paramIMAdRequest.getCurrentLocation());
            b(true);
          }
        }
        else
        {
          return;
        }
        g();
        if (d())
          continue;
        e();
        continue;
      }
      finally
      {
      }
      label78: a(true);
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.inmobi.androidsdk.impl.UserInfo
 * JD-Core Version:    0.6.2
 */